package com.guo.core.framework.tomcatStudy.Connector;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @projectName: 接口梳理
 * @package: com.guo.core.framework.tomcatStudy.Connector
 * @className: HttpConnector
 * @author: zhangcan30
 * @description: TODO
 * @date: 2023/6/27 11:25
 * @version: 1.0
 */
public class HttpConnector implements Runnable{
    boolean stopped;
    private String schema="http";

    public String getSchema(){
        return schema;
    }

    @Override
    public void run() {
        ServerSocket serverSocket=null;
        int port=8080;
        try {
            serverSocket=new ServerSocket(port,1, InetAddress.getByName("127.0.0.1"));
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
        while (!stopped){
            Socket socket=null;
            try {
                socket=serverSocket.accept();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public void start(){
        Thread thread=new Thread(this);
        thread.start();
    }
}
